<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BUIOperationFlow
 *
 * @author I062261
 */
class BUIOperationFlow extends BUINode {   
    
    public function onRender($data = NULL) {
        parent::onRender($data);        
        $this->addRenderView('operationFlowTopBar', 'operationFlow_topBar');
        
        //add controls
        if (Blyn::app()->getActiveOperation() != NULL) {
            $uiOp = Blyn::app()->getActiveOperation()->getUIManager();
        } else {
            $uiOp = new BUIOperation();
        }
        $this->addControl($uiOp);
        
        /*

        if (Blyn::app()->getUIManager()->getCurrentScreenFlow() != NULL) {
            $uiScnFlow = Blyn::app()->getUIManager()->getCurrentScreenFlow();
        } else {
            $uiScnFlow = new BUIScreenFlow('');
        }
        $uiOp->addControl($uiScnFlow);

        if (Blyn::app()->getUIManager()->getCurrentScreen() != NULL) {
            $uiScreen = Blyn::app()->getUIManager()->getCurrentScreen();
        } else {
            $uiScreen = new BUIScreen();
        }
        $uiScnFlow->addControl($uiScreen);
         * 
         */
    }   

    public function getStartScreen($data = NULL) {

        $flow = $this->getNode();
        $screenConfig = $flow->getConfigManager()->getConfigManager('screen');

        if ($screenConfig != NULL) {

            $layout = isset($screenConfig['layoutView']) ? $screenConfig['layoutView'] : BUIScreen::Default_LayoutView;
            $class = isset($screenConfig['class']) ? $screenConfig['class'] : 'BUIScreen';

            if ($this->startScreen == NULL)
                $this->startScreen = new $class();
            $this->startScreen->setLayoutView($layout);
            return $this->startScreen;
        }

        return parent::getStartScreen($data);
    }

    public function getStartScreenFlow($data = NULL) {

        $flow = $this->getNode();
        $sflowConfig = $flow->getConfigManager()->getConfigManager('screenFlow');

        if ($sflowConfig != NULL) {

            $layout = isset($sflowConfig['layoutView']) ? $sflowConfig['layoutView'] : BUIScreenFlow::Default_LayoutView;
            $class = isset($sflowConfig['class']) ? $sflowConfig['class'] : 'BUIScreenFlow';

            if ($this->startScreenFlow == NULL)
                $this->startScreenFlow = new $class();
            $this->startScreenFlow->setLayoutView($layout);
            return $this->startScreenFlow;
        }

        return parent::getStartScreenFlow($data);
    }
    
    public function getAjaxContainerId($data = NULL) {
        return 'b_show_operationFlow_content';
    }
    
    public function getAngularControllerDefine($data = NULL) {
        return 'bngOperationFlowController';
    }

}

?>
